using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;

public class UIManager : MonoBehaviour
{
    public static UIManager In;

    public GameObject BeginPanelObj;
    public GameObject GamePanelObj;

    public TextMeshProUGUI txtAll;
    public TextMeshProUGUI txtAllSign;
    public TextMeshProUGUI txtAllCap;
    public TextMeshProUGUI txtAllCapSign;

    public GameObject SignBtnObj;
    public GameObject CaptureBtnObj;

    public GameObject TipPanelObj;
    public TextMeshProUGUI txtTipAll;
    public TextMeshProUGUI txtTipSign;

    private void Awake()
    {
        In = this;
        BeginPanelObj.SetActive(true);
        GamePanelObj.SetActive(false);
    }

    public void Refresh()
    {
        switch (GameManager.In.State)
        {
            case GameState.Begin:
                BeginPanelObj.SetActive(true);
                GamePanelObj.SetActive(false);
                TipPanelObj.SetActive(false);
                break;
            case GameState.Sign:
                BeginPanelObj.SetActive(false);
                GamePanelObj.SetActive(true);
                SignBtnObj.SetActive(true);
                CaptureBtnObj.SetActive(false);
                TipPanelObj.SetActive(false);
                RefreshData();
                break;
            case GameState.Capture:
                SignBtnObj.SetActive(false);
                CaptureBtnObj.SetActive(true);
                TipPanelObj.SetActive(false);
                RefreshData();
                break;
            case GameState.AfterCapture:
                TipPanelObj.SetActive(true);
                RefreshData();
                break;
        }
    }

    private void RefreshData()
    {
        var data = GameData.In;
        txtAll.text = $"全部小鸟：{(data.IsShowBirdNums? data.BirdNums.ToString() : "？")}";
        txtAllSign.text = $"已标记小鸟：<color=#63A6C4>{data.SignBirdNums}</color>";
        txtAllCap.text = $"捕获小鸟总数：{data.AllCaptureBirdNums}";
        txtAllCapSign.text = $"捕获带标记小鸟总数：<color=#63A6C4>{data.AllCaptureSignBirdNums}</color>";
        if (GameManager.In.State == GameState.AfterCapture)
        {
            txtTipAll.text = $"捕获小鸟：{data.LastCaptureBirdNums}只";
            txtTipSign.text = $"捕获小鸟带标记：<color=#63A6C4>{data.LastCaptureSignBirdNums}</color>只";
        }
    }
}
